package servlet;

import dao.GoodsDao;
import pojo.Goods;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author konley
 * @date 2020-06-20 14:09
 */
@WebServlet("/ShowGoods")
public class ShowGoods extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int id = Integer.parseInt(request.getParameter("id"));
        Goods goods = new GoodsDao().getGoodsById(id);
        request.setAttribute("goods",goods);
        request.getRequestDispatcher("/showGoods.jsp").forward(request,response);
    }
}
